home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / timeline / connect.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  5.6 KB  |  145 lines

  1. /*
  2.  * Copyright (c) 1990, 1991 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and 
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that (i) the above copyright notices and this permission notice appear in
  7.  * all copies of the software and related documentation, and (ii) the name
  8.  * Stanford may not be used in any advertising or publicity relating to
  9.  * the software without the specific, prior written permission of
  10.  * Stanford.
  11.  * 
  12.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  13.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  14.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  15.  *
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  17.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
  18.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT
  19.  * ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY,
  20.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21.  * SOFTWARE.
  22.  */
  23.  
  24. /* $Header: /Source/Media/collab/TimeLine/RCS/connect.c,v 1.1 91/10/03 17:40:01 chua Exp Locker: drapeau $ */
  25. /* $Log:    connect.c,v $
  26.  * Revision 1.1  91/10/03  17:40:01  chua
  27.  * *** empty log message ***
  28.  * 
  29.  * Revision 1.0  91/09/30  16:50:12  chua
  30.  * Initial revision
  31.  *  */
  32.  
  33. static char connectrcsid[] = "$Header: /Source/Media/collab/TimeLine/RCS/connect.c,v 1.1 91/10/03 17:40:01 chua Exp Locker: drapeau $";
  34.  
  35. #include "main.h"
  36.  
  37. /*
  38.  * Notify callback function for `NewPortManagerText'.
  39.  * Calls the notify function for the ConnectPortManagerButton when a return is pressed.
  40.  */
  41. Panel_setting NewPortManager(item, event)
  42.      Panel_item    item;
  43.      Event        *event;
  44. {
  45.   ConnectPortManager(item, NULL);
  46.   return panel_text_notify(item, event);
  47. }
  48.  
  49. /*
  50.  * Notify callback function for `ConnectPortManagerButton'.
  51.  * This function will take the name specifed on the NewPortManagerText textfield and attempt to make a connection 
  52.  * with the port manager on this host.  If it succeeds, it will disconnect from the previous port manager it was connected to (if any).
  53.  */
  54. void ConnectPortManager(item, event)
  55.      Panel_item    item;
  56.      Event        *event;
  57. {
  58.   Sender *tempSender;
  59.   char buf[100];
  60.   ConnectPortManager_PortManagerPopup_objects    *ip = (ConnectPortManager_PortManagerPopup_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  61.   TimeLineFramePtr tlFrame;
  62.   Window    owner = xv_get(ip->PortManagerPopup, XV_OWNER);
  63.   TimeLine_window_objects * tlip = (TimeLine_window_objects *) xv_get(owner, XV_KEY_DATA, INSTANCE);
  64.  
  65.   tlFrame = TimeLineWindow[xv_get(tlip->controls, PANEL_CLIENT_DATA)];
  66.  
  67.  
  68.   if (strcmp(tlFrame->TimeLinePort.hostName,                /* Do not reconnect if it is the same host, just do an update apps */
  69.          (char *) xv_get(ip->NewPortManagerText, PANEL_VALUE)) == 0) 
  70.   {
  71.     UpdateAppsHandler(tlFrame->TimeLine_window->appButton, MENU_NOTIFY);
  72.     return;
  73.   }
  74.   if (CheckChanges(ConnectPM, tlFrame) == NOTICE_YES)            /* check if unsaved changes exist */
  75.     return;
  76.   strcpy(tlFrame->TimeLinePort.hostName, (char *) xv_get(ip->NewPortManagerText, PANEL_VALUE));
  77.   tempSender = NewSender(&(tlFrame->TimeLinePort));
  78.   if (tempSender)
  79.   {
  80.     if (tlFrame->TimeLineSender && tlFrame->TimeLineReceiver)        /* Disconnect from previous Port Manager (if any) */
  81.       DestroyReceiver(tlFrame->TimeLineSender, tlFrame->TimeLineReceiver);
  82.     tlFrame->TimeLineSender = tempSender;
  83.     tlFrame->TimeLineReceiver = NewReceiver(tlFrame->TimeLineSender, "TimeLine", ReceiverPortNumber);
  84.     sprintf(buf, "Current Port Manager : %s\n", tlFrame->TimeLinePort.hostName);
  85.     xv_set(ip->CurrentPortManagerMsg, PANEL_LABEL_STRING, buf, NULL);
  86.     FreePause(tlFrame);
  87.     UpdatePauseList(tlFrame, 0);
  88.     ClearAllRegion(tlFrame->RegionPopup->ClearAllRegionButton, NULL); /* Clear all the region */
  89.     FreeInstrumentList(tlFrame);
  90.     strcpy(tlFrame->filename, "untitled");
  91.     tlFrame->change = 0;
  92.     UpdateHeader(tlFrame, 0);
  93.     OpenAppsInitialize(tlFrame, 1);                    /* Get the new list of open applications from the new Port Manager */
  94.     SetCanvasHeight(tlFrame);
  95.     AppCanvasRepaintHandler(tlFrame->TimeLine_window->AppCanvas, tlFrame->paintWinApp, 
  96.                 tlFrame->dpyApp, tlFrame->xidApp, NULL);
  97.     ScrollToFirstQuarter(tlFrame, 0, 1);
  98.   }
  99.   else 
  100.     AlertMessage(tlFrame, "Failed to connect with the PortManager.",
  101.          "Check that the hostname is valid, and that the PortManager is running on it.", NULL);
  102. }
  103.  
  104. /*
  105.  * Notify callback function for `ClosePortManagerPopupButton'.
  106.  * Close the Connect Port Manager popup window
  107.  */
  108. void ClosePortManagerPopup(item, event)
  109.      Panel_item    item;
  110.      Event        *event;
  111. {
  112.   ConnectPortManager_PortManagerPopup_objects    *ip = (ConnectPortManager_PortManagerPopup_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  113.  
  114.   xv_set(ip->PortManagerPopup, FRAME_CMD_PUSHPIN_IN, FALSE, NULL);
  115.   xv_set(ip->PortManagerPopup, XV_SHOW, FALSE, NULL);
  116. }
  117.  
  118. /*
  119.  * Menu handler for `OptionsMenu (Connect with new Port Manager ...)'.
  120.  * Open the popup window to choose a new port manager to connect to.
  121.  */
  122. Menu_item ConnectPortManagerHandler(item, op)
  123.      Menu_item    item;
  124.      Menu_generate    op;
  125. {
  126.   TimeLineFramePtr tlFrame;
  127.   TimeLine_window_objects * ip = (TimeLine_window_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  128.  
  129.   tlFrame = TimeLineWindow[xv_get(ip->controls, PANEL_CLIENT_DATA)];
  130.   switch (op) 
  131.   {
  132.    case MENU_DISPLAY:
  133.     break;
  134.    case MENU_DISPLAY_DONE:
  135.     break;
  136.    case MENU_NOTIFY:
  137.     xv_set(tlFrame->PortManagerPopup->PortManagerPopup, FRAME_CMD_PUSHPIN_IN, TRUE, NULL);
  138.     xv_set(tlFrame->PortManagerPopup->PortManagerPopup, XV_SHOW, TRUE, NULL);
  139.     break;
  140.    case MENU_NOTIFY_DONE:
  141.     break;
  142.   }
  143.   return item;
  144. }
  145.